using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace GodSoft.Models.Mapping
{
    public class LightMap : EntityTypeConfiguration<Light>
    {
        public LightMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.LightName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Address)
                .HasMaxLength(50);

            this.Property(t => t.Brand)
                .HasMaxLength(50);

            this.Property(t => t.Company)
                .HasMaxLength(50);

            this.Property(t => t.Information)
                .HasMaxLength(50);

            this.Property(t => t.Province)
                .HasMaxLength(50);

            this.Property(t => t.City)
                .HasMaxLength(50);

            this.Property(t => t.District)
                .HasMaxLength(50);

            this.Property(t => t.Street)
                .HasMaxLength(50);

            this.Property(t => t.StreetNumber)
                .HasMaxLength(50);

            this.Property(t => t.Logo)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Light");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.TypeID).HasColumnName("TypeID");
            this.Property(t => t.LightName).HasColumnName("LightName");
            this.Property(t => t.CenterLng).HasColumnName("CenterLng");
            this.Property(t => t.CenterLat).HasColumnName("CenterLat");
            this.Property(t => t.Zoom).HasColumnName("Zoom");
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.CreateTime).HasColumnName("CreateTime");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Brand).HasColumnName("Brand");
            this.Property(t => t.Company).HasColumnName("Company");
            this.Property(t => t.Information).HasColumnName("Information");
            this.Property(t => t.Province).HasColumnName("Province");
            this.Property(t => t.City).HasColumnName("City");
            this.Property(t => t.District).HasColumnName("District");
            this.Property(t => t.Street).HasColumnName("Street");
            this.Property(t => t.StreetNumber).HasColumnName("StreetNumber");
            this.Property(t => t.Logo).HasColumnName("Logo");

            // Relationships
            this.HasRequired(t => t.DeviceType)
                .WithMany(t => t.Lights)
                .HasForeignKey(d => d.TypeID);

        }
    }
}
